package com.lagou.ipersistence.executor.result;

import com.lagou.ipersistence.reflection.factory.ObjectFactory;
import com.lagou.ipersistence.session.ResultContext;
import com.lagou.ipersistence.session.ResultHandler;

import java.util.List;

/**
 * @author Yan Jiahong
 * Created on 2020/11/23
 */
public class DefaultResultHandler implements ResultHandler<Object> {
    private final List<Object> list;
    
    public DefaultResultHandler(ObjectFactory objectFactory) {
        list = objectFactory.create(List.class);
    }
    
    @Override
    public void handleResult(ResultContext<?> resultContext) {
        list.add(resultContext.getResultObject());
    }
    
    public List<Object> getList() {
        return list;
    }
}
